﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Shapes;
using System.Windows.Media;

namespace mat2tab_fun.functionPlots
{
    class ExponentialFunctionPlot : FunctionPlot
    {
        public ExponentialFunctionPlot(bool testMonotonicznosci, Grid plotGrid, int size, int a, double b, int c)
            : base(testMonotonicznosci, plotGrid, size)
        {
            double delta = 0.05;
            if (b != 0)
            {
                for (double x = -halfX / size; x <= halfX / size; )
                {
                    Line l = new Line();
                    l.X1 = x * size + halfX;
                    l.Y1 = (a * Math.Pow(b, x) + c) * size;

                    if (l.Y1 >= 0)
                        l.Y1 = halfY - l.Y1;
                    else
                        l.Y1 = l.Y1 * (-1) + halfY;

                    x += delta;

                    l.X2 = x * size + halfX;
                    l.Y2 = (a * Math.Pow(b, x) + c) * size;

                    if (l.Y2 >= 0)
                        l.Y2 = halfY - l.Y2;
                    else
                        l.Y2 = l.Y2 * (-1) + halfY;
                    if (testMonotonicznosci)
                    {
                        if (l.Y1 > l.Y2)
                            l.Stroke = Brushes.Red;
                        else
                            l.Stroke = Brushes.Green;
                    }
                    else
                        l.Stroke = Brushes.Blue;
                    if (Math.Abs(l.Y1 - l.Y2) < 350)
                        lines.Add(l);
                }
                DrawPlot();
            }
        }
    }
}
